#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    //treewidget 树控件的使用
    //创建两个头
    ui->treeWidget ->setHeaderLabels(QStringList()<<"英雄"<<"英雄介绍");
    //创建三个根节点
    QTreeWidgetItem * liitem = new QTreeWidgetItem(QStringList()<<"力量");
    QTreeWidgetItem * miitem = new QTreeWidgetItem(QStringList()<<"敏捷");
    QTreeWidgetItem * zhiitem = new QTreeWidgetItem(QStringList()<<"智力");
    //将根节点加入到树
    ui->treeWidget->addTopLevelItem(liitem);
    ui->treeWidget->addTopLevelItem(miitem);
    ui->treeWidget->addTopLevelItem(zhiitem);

    //为根节点加子节点
    QStringList hero1 ;
    hero1<<"钢背"<<"坦克";
    QTreeWidgetItem * l1 = new QTreeWidgetItem(hero1);
    liitem->addChild(l1);

}

Widget::~Widget()
{
    delete ui;
}
